package com.mop.sg2.map;

import org.apache.mina.core.service.IoHandler;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

public class MessageHandle implements IoHandler {
	public static IoSession session = null;
	static int index = 1;

	@Override
	public void exceptionCaught(IoSession arg0, Throwable arg1)
			throws Exception {
		System.out.println("exceptionCaught");
	}

	@Override
	public void messageReceived(IoSession arg0, Object arg1) throws Exception {
		System.out.println("messageReceived");

	}

	@Override
	public void messageSent(IoSession arg0, Object arg1) throws Exception {
		System.out.println("messageSent");
	}

	@Override
	public void sessionClosed(IoSession arg0) throws Exception {
		System.out.println("sessionClosed");
		session = null;
	}

	@Override
	public void sessionCreated(IoSession arg0) throws Exception {
		System.out.println("sessionCreated");
		session = arg0;
	}

	@Override
	public void sessionIdle(IoSession arg0, IdleStatus arg1) throws Exception {
		// System.out.println("sessionIdle");
		// if (session != null) {
		// MessageExample e = new MessageExample();
		// e.setName("Jay 黄 Server" + index);
		// e.setYear(2011 + index);
		// e.setSex((short) index);
		// e.setM(2.1314 + index);
		// index++;
		// session.write(e);
		// }
	}

	@Override
	public void sessionOpened(IoSession arg0) throws Exception {
		System.out.println("sessionOpened");
	}

}
